package ssx.demo.redisson_redlock_demo.conf;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ConfRedis {

    @Value("${spring.redis.host1}")
    private String address1;
     @Value("${spring.redis.host2}")
    private String address2;
     @Value("${spring.redis.host3}")
    private String address3;


    /**
     * 配置redis连接池 默认连接池数量是：25？？ 忘记了 spring boot 启动时会提示
     * @return
     */
    @Bean("myRedissonClient")
    public RedissonClient getRedis1(){
        Config config = new Config();
//        config.useClusterServers()
//                .addNodeAddress(address1,address2,address3)
//                .setPassword("1");
        config.useSingleServer().setAddress(address1).setPassword("1");
        return Redisson.create(config);
    }

}
